const sql = require('mssql');

function SQLServerDB () {

  this.connected = false;
  this.sqlReqeust = null;

  this.getRequest = () => {
    return new Promise((resolve, reject) => {
      if (this.sqlReqeust) {
        resolve(this.sqlReqeust);
      } else {
        sql.connect('mssql://sa:Aa456654@47.114.179.84:2433/BlueKey').then(function() {
          this.sqlReqeust = new sql.Request();
          resolve(this.sqlReqeust)
        }).catch(function(err) {
          reject(err)
        })
      }
    })
  }
}

module.exports = SQLServerDB;